home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 36 / dvpif10.zip / PIFEDIT.C < prev    next >
C/C++ Source or Header  |  1991-03-31  |  7KB  |  193 lines

  1. /**********************************************************************/
  2. /**                                                                  **/
  3. /**   Module-Name : PIFEDIT.C             Version : 1.0              **/
  4. /**                                                                  **/
  5. /**   Last Update : 22.01.91              by J. Braeuchi             **/
  6. /**                                                                  **/
  7. /**********************************************************************/
  8. /**                                                                  **/
  9. /**   Description : Edit Desqview PIFs                               **/
  10. /**                                                                  **/
  11. /**********************************************************************/
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include <conio.h>
  17. #include <ctype.h>
  18.  
  19.  
  20. typedef unsigned char byte;
  21. typedef unsigned int  word;
  22.  
  23. struct PIF {
  24.         word reserv1;
  25.         char pgmtitle[30];
  26.         unsigned int maxmem,minmem;
  27.         char pgmname[64],pgmdrive[1],pgmdir[64],pgmparms[64];
  28.         byte screen,txtpages,firstint,lastint,rows,cols,
  29.          inirow,inicol;
  30.         word sysmem;
  31.         char sharepgm[64],sharepgmdata[64];
  32.         byte control1,control2;
  33.         char keys[2];
  34.         word scriptbuf,pause;
  35.         byte colormap,swappable;
  36.         char reserv2[3];
  37.         byte autoclose,usedisk;
  38.         byte dv_version;
  39.         byte reserv3;
  40.         byte pinirows,pinicols;
  41.         word maxems;
  42.         byte control3,kbdconflict,graphpages;
  43.         word x_sysmem;
  44.         byte iniscreen;
  45.         byte serialports,control4,protect;
  46.         char reserv4[19];
  47.        };
  48.          
  49. /*** Globals **********************************************************/
  50.  
  51. struct PIF pif;
  52. char name[80]="C:\\DV\\DUMMY.DVP";
  53.  
  54. /**********************************************************************/
  55. /*                                                                    */
  56. /*    Function-Name : show_pif                                        */
  57. /*                                                                    */
  58. /*    Descr  : Show Pif-Data                                          */
  59. /*    Input  :                                                        */
  60. /*    Output :                                                        */
  61. /*                                                                    */
  62. /**********************************************************************/
  63. void show_pif(void)
  64. {
  65.  clrscr();
  66.  cprintf("**** DesqView PIF-Editor ****     by J.Braeuchi ");
  67.  cprintf("\n\n\rPIF-File : %s\n",name);
  68.  cprintf("\n\rA)  Title      : %.30s",pif.pgmtitle); 
  69.  cprintf("\n\rB)  Keys       : %.2s",pif.keys);
  70.  cprintf("\n\rC)  Memory     : %dK max,%dK min,%dK System,%d Script",
  71.     pif.maxmem,pif.minmem,pif.sysmem,pif.scriptbuf);
  72.  cprintf("\n\rD)  Program    : %.64s",pif.pgmname);
  73.  cprintf("\n\rE)  Directory  : %.1s:%.64s",pif.pgmdrive,pif.pgmdir);
  74.  cprintf("\n\rF)  Parms      : %.64s",pif.pgmparms);
  75.  cprintf("\n\rG)  max.EMS    : %d",pif.maxems);
  76.  cprintf("\n\rH)  Window     : %u Rows %u Cols",pif.pinirows,pif.pinicols);
  77.  cprintf("\n\rI)  Position   : %u Row  %u Col",pif.inirow,pif.inicol);
  78.  cprintf("\n\rK)  SharePgm   : %.64s",pif.sharepgm);
  79.  cprintf("\n\rL)  ...Data    : %.64s",pif.sharepgmdata);
  80.  cprintf("\n\n\rU)  Update PIF-File");
  81.  cprintf("\n\rX)  Exit without update");
  82. }
  83.  
  84.  
  85. /**********************************************************************/
  86.  
  87.  
  88. void main(int argc,char *argv[])
  89. {
  90.  FILE *dvp;
  91.  char inbuf[81];                              /* Raw Input            */ 
  92.  char scanbuf[81];                            /* Scanned Input        */
  93.  short scanint1,scanint2;
  94.  int choice;                                  
  95.  
  96.  if (argc > 1) strcpy(name,strupr(argv[1]));
  97.  
  98.  dvp = fopen(name,"rb+");                     /* read/write binary    */
  99.  if (dvp == NULL)
  100.  {
  101.   cprintf("\n\rCan't open '%s'.",argv[1]);
  102.   exit(12);
  103.  }
  104.  
  105.  fread(&pif,sizeof(struct PIF),1,dvp);
  106.  
  107.  do
  108.  {
  109.   show_pif();
  110.   cprintf("\n\n\rSelect Item");
  111.   choice = _toupper(getch());
  112.   switch (choice)
  113.   {
  114.    case 'A' : cprintf("\n\n\r>> Title : ");
  115.           gets(inbuf);
  116.           sscanf(inbuf,"%30[A-Z a-z1-9]",scanbuf);
  117.           memcpy(pif.pgmtitle,scanbuf,30);
  118.           break;
  119.    case 'B' : cprintf("\n\n\r>> Keys : ");
  120.           gets(inbuf);
  121.           sscanf(inbuf,"%2s",scanbuf);
  122.           memcpy(pif.keys,scanbuf,2);
  123.           break;
  124.    case 'C' : cprintf("\n\n\r>> Memory (max min sys script) : ");
  125.           gets(inbuf);
  126.           sscanf(inbuf,"%u %u %u %u",
  127.              &pif.maxmem,&pif.minmem,
  128.              &pif.sysmem,&pif.scriptbuf);
  129.           break;
  130.    case 'D' : cprintf("\n\n\r>> Program : ");
  131.           gets(inbuf);
  132.           sscanf(inbuf,"%64[A-Z a-z1-9]",scanbuf);
  133.           memcpy(pif.pgmname,scanbuf,64);
  134.           break;
  135.    case 'E' : cprintf("\n\n\r>> Directory : ");
  136.           gets(inbuf);
  137.           sscanf(inbuf,"%66s",scanbuf);
  138.           if(scanbuf[1] == ':')
  139.           {
  140.            memcpy(pif.pgmdrive,scanbuf,1);
  141.            memcpy(pif.pgmdir,scanbuf+2,64);
  142.           }
  143.           else
  144.           {
  145.            memcpy(pif.pgmdir,scanbuf,64);
  146.           }
  147.           break;
  148.    case 'F' : cprintf("\n\n\r>> Parms : ");
  149.           gets(inbuf);
  150.           sscanf(inbuf,"%64[!-~ ]",scanbuf);
  151.           memcpy(pif.pgmparms,scanbuf,64);
  152.           break;
  153.    case 'G' : cprintf("\n\n\r>> max. EMS : ");
  154.           gets(inbuf);
  155.           sscanf(inbuf,"%u",&pif.maxems);
  156.           break;
  157.    case 'H' : cprintf("\n\n\r>> Window (rows cols) : ");
  158.           gets(inbuf);
  159.           sscanf(inbuf,"%u %u",&scanint1,&scanint2);
  160.           pif.pinirows = (byte)scanint1;
  161.           pif.pinicols = (byte)scanint2;
  162.           if((scanint1 == 0) && (scanint2 == 0))
  163.         pif.control3 |= 0x80;         /* Automatic Position   */
  164.           else
  165.         pif.control3 &= 0xFF - 0x80;  /* take Parameters      */
  166.           break;
  167.    case 'I' : cprintf("\n\n\r>> Position (row col) : ");
  168.           gets(inbuf);
  169.           sscanf(inbuf,"%u %u",&scanint1,&scanint2);
  170.           pif.inirow = (byte)scanint1;
  171.           pif.inicol = (byte)scanint2;
  172.           break;
  173.    case 'K' : cprintf("\n\n\r>> Shared Program : ");
  174.           gets(inbuf);
  175.           sscanf(inbuf,"%64s",scanbuf);
  176.           memcpy(pif.sharepgm,scanbuf,64);
  177.           break;
  178.    case 'L' : cprintf("\n\n\r>> Shared Program Data : ");
  179.           gets(inbuf);
  180.           sscanf(inbuf,"%64[!-~ ]",scanbuf);
  181.           memcpy(pif.sharepgmdata,scanbuf,64);
  182.           break;
  183.    case 'U' : fseek(dvp,0L,SEEK_SET);
  184.           fwrite(&pif,sizeof(struct PIF),1,dvp);
  185.           break;
  186.   }
  187.  } while((choice != 'X') && (choice != 'U'));
  188.  
  189.  fclose(dvp);
  190. }
  191.  
  192. /************************** End of Module *****************************/
  193.